package recovery

import (
	"Hypnos-Soundcore/components/helper"
	"Hypnos-Soundcore/constants"
	"fmt"
)

func WrapGo(fn func()) {
	go func() {
		defer func() {
			if err := recover(); err != nil {
				stack := stack(3)
				message := fmt.Sprintf("%s", helper.ReplaceNewline(string(stack)))
				helper.ErrorActionPrintf(constants.TagRecovery, "recovery", " err:%v;stack message:%v", err, message)
			}
		}()
		fn()
	}()
}
